/**首页的表格配置 */
export const getOption = () => {
  return {
    calcHeight: 30,
    tip: false,
    height: 'calc(100vh - 440px)',
    searchShow: true,
    // searchSpan: 4,
    searchMenuPosition: 'right',
    searchMenuSpan: 4,
    dialogClickModal: false,
    border: true,
    viewBtn: false,
    addBtn: false,
    selection: true,
    printBtn: false,
    editBtn: false,
    delBtn: false,
    index: true,
    indexLabel: '序号',
    searchSpan: 5,
    columnBtn: false,
    column: [
      {
        label: '单据号',
        prop: 'sheetNo',
        search: true,
        rules: [
          {
            required: true,
            message: '请输入单据号',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '单据类型',
        prop: 'sheetType',
        search: true,
        type: 'select',
        dicUrl: '/api/blade-system/dict/dictionary?code=sheet_type',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        }
      },
      {
        label: '单据日期',
        prop: 'sheetDate'
      },
      {
        label: '单据状态',
        prop: 'status',
        search: true,
        type: 'select',
        dicUrl: '/api/blade-system/dict/dictionary?code=sheet_status',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        }
      },
      {
        label: '单据来源',
        prop: 'generationType',
        search: true,
        type: 'select',
        dicUrl: '/api/blade-system/dict/dictionary?code=sheet_source',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        }
      },
      {
        label: '供应商代码',
        prop: 'partnerCode',
        rules: [
          {
            required: true,
            message: '请输入供应商代码',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '供应商名称',
        prop: 'partnerName',
        rules: [
          {
            required: true,
            message: '请输入供应商代码',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '负责人',
        prop: 'principal',
        rules: [
          {
            required: true,
            message: '请输入负责人',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '最后一次成功同步时间',
        prop: 'lastSuccessSyncTime',
        sortable: true,
        rules: [
          {
            required: true,
            message: '请输入最后一次成功同步时间',
            trigger: 'blur'
          }
        ]
      }
    ]
  };
};

/**
 * 获取单据类型配置
 */
export const getTypeOption = (safa) => {
  return {
    labelWidth: '110',
    submitBtn: false,
    emptyBtn: false,
    column: [
      {
        label: '单据类型',
        prop: 'sheetType',
        search: true,
        type: 'select',
        value: 'PO',
        dicUrl: '/api/blade-system/dict/dictionary?code=sheet_type',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        },
        dicFormatter: (data) => {
          return safa._filter(data.data, (item) => {
            return item.dictKey !== 'SCRAP';
          });
        },
        rules: [
          {
            required: true,
            message: '请输入选择单据类型',
            trigger: 'blur'
          }
        ],
        change: (val) => {
          safa.judgeType(val.value);
          if (safa.title === '新增') {
            safa.receiveRecordNumber = '';
            safa.addDis(val.value);
          }
        }
      }
    ]
  };
};

/**
 * 采购单表单配置
 */
export const getPoColumn = (safa) => {
  return [
    {
      label: '采购日期',
      prop: 'sheetDate',
      type: 'datetime',
      format: 'yyyy-MM-dd HH:mm:ss',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      rules: [
        {
          required: true,
          message: '请输入采购日期',
          trigger: 'blur'
        }
      ]
    },
    {
      label: '单据状态',
      prop: 'status',
      type: 'select',
      disabled: false,
      display: true,
      dicUrl: '/api/blade-system/dict/dictionary?code=sheet_status',
      props: {
        label: 'dictValue',
        value: 'dictKey'
      }
    },
    {
      label: '供应商',
      prop: 'partnerName',
      type: 'search',
      placeholder: '请选择 供应商',
      disabled: true,
      rules: [
        {
          required: true,
          message: '请选择供应商',
          trigger: 'blur'
        }
      ],
      appendClick: () => {
        if (safa.title !== '查看') {
          if (!safa.receiveRecordNumber && safa.title === '编辑') {
            safa.openPartnerModal();
          } else if (safa.title === '新增') {
            safa.openPartnerModal();
          }
        }
      }
    }
  ];
};

/**
 * 退料单表单配置
 *
 */
export const getBsColumn = (safa) => {
  return [
    {
      label: '领料单',
      prop: 'sheetNo',
      type: 'search',
      disabled: true,
      rules: [
        {
          required: true,
          message: '请输入领料单',
          trigger: 'blur'
        }
      ],
      appendClick: () => {
        if (safa.title !== '查看') {
          safa.openRoSheetCommonModal();
        }
      }
    },
    {
      label: '关联工单',
      prop: 'sourceNo',
      disabled: true
    },
    {
      label: '退料原因',
      prop: 'description',
      type: 'textarea',
      disabled: false,
      maxRows: 3,
      minRows: 3,
      rules: [
        {
          required: true,
          message: '请输入退料原因',
          trigger: 'blur'
        }
      ]
    }
  ];
};

/**
 * 领料单表单配置
 */
export const getRoColumn = (safa) => {
  return [
    {
      label: '生产工单',
      prop: 'sourceNo',
      type: 'search',
      disabled: true,
      rules: [
        {
          required: true,
          message: '请输入生产工单',
          trigger: 'blur'
        }
      ],
      appendClick: () => {
        if (safa.title !== '查看') {
          safa.openWorkOrderModal();
        }
      }
    },
    {
      label: '产品编码',
      prop: 'partNo',
      disabled: true,
      rules: [
        {
          required: true,
          message: '请输入产品编码',
          trigger: 'blur'
        }
      ]
    },
    {
      label: '产品名称',
      prop: 'partName',
      disabled: true,
      rules: [
        {
          required: true,
          message: '请输入产品名称',
          trigger: 'blur'
        }
      ]
    },
    {
      label: '数量',
      prop: 'planQuantity',
      disabled: true,
      rules: [
        {
          required: true,
          message: '请输入数量',
          trigger: 'blur'
        }
      ]
    },
    {
      label: 'BOM版本',
      prop: 'bomVersion',
      disabled: true,
      rules: [
        {
          required: true,
          message: '请输入BOM版本',
          trigger: 'blur'
        }
      ]
    }
  ];
};

/**
 * 采购单表格配置
 */

export const getPoTableColumn = (safa) => {
  return [
    {
      label: '单行号',
      prop: 'sheetLot',
      type: 'number',
      precision: 0,
      minRows: '',
      maxRows: 999,
      cell: true,
      width: 200,
      rules: [
        {
          required: true,
          message: '请输入单行号',
          trigger: 'blur'
        }
      ]
    },
    {
      label: '物料编码',
      prop: 'partMasterCode'
    },
    {
      label: '物料名称',
      prop: 'partMasterName'
    },
    {
      label: '物料规格',
      prop: 'partMasterModel'
    },
    {
      label: '采购数量',
      prop: 'quantity',
      type: 'number',
      precision: 10,
      controls: false,
      minRows: '',
      cell: true,
      width: 200,
      rules: [
        {
          required: true,
          message: '请输入采购数量',
          trigger: 'blur'
        }
      ]
    },
    {
      label: '已收数量',
      prop: 'completedQuantity',
      hide: true
    }
  ];
};

/**
 * 领料单表格配置
 */
export const getRoTableColumn = () => {
  return [
    {
      label: '物料编码',
      prop: 'partMasterCode',
      type: 'search'
    },
    {
      label: '物料名称',
      prop: 'partMasterName'
    },
    {
      label: '物料规格',
      prop: 'partMasterModel'
    },
    {
      label: '物料类别',
      prop: 'categoryName'
    },
    {
      label: '单位用量',
      prop: 'unitQty',
      type: 'number',
      precision: 10
    },
    {
      label: '工单所需总量',
      prop: 'workOrderRequireQuantity',
      type: 'number',
      precision: 10
    },
    {
      label: '已领数量',
      prop: 'completedQuantity',
      type: 'number',
      precision: 10
    },
    {
      label: '领料数量',
      prop: 'quantity',
      type: 'number',
      precision: 0,
      minRows: '',
      cell: true,
      width: 200,
      rules: [
        {
          required: true,
          message: '请输入领料数量',
          trigger: 'blur'
        }
      ]
    }
  ];
};

/**
 * 来料入库单表格配置
 */

export const getMoTableColumn = () => {
  return [
    {
      label: '采购单号',
      prop: 'sheetNo',
      type: 'search'
    },
    {
      label: '物料编码',
      prop: 'partMasterCode'
    },
    {
      label: '物料名称',
      prop: 'partMasterName'
    },
    {
      label: '物料批次',
      prop: 'lotNo'
    },
    {
      label: '实收数量',
      prop: 'quantity'
    }
  ];
};

/**
 * 成品入库单表格配置
 */
export const getFoTableColumn = () => {
  return [
    {
      label: '工单单号',
      prop: 'sourceNo',
      type: 'search'
    },
    {
      label: '检验单号',
      prop: 'documentNo',
      type: 'search'
    },
    {
      label: '产品编码',
      prop: 'partMasterCode'
    },
    {
      label: '产品名称',
      prop: 'partMasterName'
    },
    {
      label: '产品数量',
      prop: 'quantity',
      type: 'number'
    }
  ];
};

export const getBsTableColumn = (safe) => {
  return [
    {
      label: '物料编码',
      prop: 'partMasterCode',
      type: 'search'
    },
    {
      label: '物料名称',
      prop: 'partMasterName'
    },
    {
      label: '物料规格',
      prop: 'partMasterModel'
    },
    {
      label: '领用数量',
      prop: 'requisitionQuantity'
    },
    {
      label: '已退数量',
      prop: 'completedQuantity'
    },
    {
      label: '退料数量',
      prop: 'quantity',
      type: 'number',
      precision: 0,
      minRows: '',
      cell: true,
      width: 200
    }
  ];
};

/**
 * 报废入库单表格配置
 */
export const getScrapTableColumn = () => {
  return [
    {
      label: '产品序列号/包装条码',
      prop: 'productSequenceNumber',
      type: 'search'
    },
    {
      label: '报废类型',
      prop: 'scrapType',
      type: 'select',
      dicUrl: '/api/blade-system/dict/dictionary?code=scrapType',
      props: {
        label: 'dictValue',
        value: 'dictKey'
      }
    },
    {
      label: '产品编码',
      prop: 'partMasterCode'
    },
    {
      label: '产品名称',
      prop: 'partMasterName'
    },
    {
      label: '产品型号',
      prop: 'partMasterModel'
    },
    {
      label: '数量',
      prop: 'quantity'
    },
    {
      label: '报废执行人',
      prop: 'scrapHandleBy'
    },
    {
      label: '报废执行时间',
      prop: 'scrapHandleTime'
    }
  ];
};

/**
 * 包装条码配置
 */
export const getPackIdOption = () => {
  return {
    height: '400',
    addBtn: false,
    viewBtn: false,
    selection: false,
    menu: false,
    page: false,
    index: false,
    refreshBtn: false,
    column: [
      {
        label: '包装条码',
        prop: 'sequenceNumber'
      },
      {
        label: '包装数量',
        prop: 'quantity'
      },
      {
        label: '入库状态',
        prop: 'status'
      },
      {
        label: '储位编码',
        prop: 'areaCode'
      },
      {
        label: '储位名称',
        prop: 'areaCode'
      },
      {
        label: '供应商编码',
        prop: 'vendorCode'
      },
      {
        label: '供应商批次',
        prop: 'vendorLotNo'
      }
    ]
  };
};
